﻿Imports FinanceiroDAL.ModuloConexao
Public Class FluxodeCaixaFRM
    Private Sub RBDia_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RBDia.CheckedChanged
        If RBDia.Checked Then
            Try
                Dim frm As New RelatoriosfinFRM
                Dim rpt As New FluxodeCaixaREL
                Try
                    rpt.SetDatabaseLogon(usuario, senha)
                    rpt.SetParameterValue(0, Date.Now.ToString("yyyy-MM-dd"))
                    rpt.SetParameterValue(1, Date.Now.ToString("yyyy-MM-dd"))
                    rpt.SetParameterValue(2, "Fluxo de Caixa - Dia")
                    frm.CrystalReportViewer2.ShowGroupTreeButton = False
                    frm.CrystalReportViewer2.ReportSource = rpt
                    frm.ShowDialog()
                Catch ex As Exception
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End Try
                frm.Dispose()
                rpt = Nothing
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Finally
            End Try
        End If
        '  gerarelatrio("Fluxo de Caixa - Dia", "{SPFluxodeCaixa.icp_datapagamento}='" & Date.Now.ToString("yyyy-MM-dd") & "' and {SPFluxodeCaixa.icp_datapagamento} <= '" & Date.Now.ToString("yyyy-MM-dd") & "'")
    End Sub

    Private Sub RBPeriodo_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RBPeriodo.CheckedChanged
        If RBPeriodo.Checked = True Then
            gbPeriodo.Enabled = True
        End If
    End Sub
    '   gerarelatrio("Fluxo de Caixa - Período", "{SPFluxodeCaixa.icp_datapagamento} >='" & dtinicio.Value.ToString("yyyy-MM-dd") & "' and {SPFluxodeCaixa.icp_datapagamento} <= '" & dtfim.Value.ToString("yyyy-MM-dd") & "'")
    Private Sub BTNok_Click(sender As System.Object, e As System.EventArgs) Handles BTNok.Click
        If RBPeriodo.Checked = True Then
            Dim opt As Integer = 0
            opt = DateTime.Compare(dtinicio.Value, dtfim.Value)
            If opt <= 0 Then
                Try
                    Dim frm As New RelatoriosfinFRM
                    Dim rpt As New FluxodeCaixaREL
                    Try
                        rpt.SetDatabaseLogon(usuario, senha)
                        rpt.SetParameterValue(0, dtinicio.Value.Date.ToString("yyyy-MM-dd"))
                        rpt.SetParameterValue(1, dtfim.Value.Date.ToString("yyyy-MM-dd"))
                        rpt.SetParameterValue(2, "Fluxo de Caixa por Período")
                        frm.CrystalReportViewer2.ShowGroupTreeButton = False
                        frm.CrystalReportViewer2.ReportSource = rpt
                        frm.ShowDialog()
                    Catch ex As Exception
                        MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                    frm.Dispose()
                    rpt = Nothing
                Catch ex As Exception
                    MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Finally

                End Try
            End If
        End If
    End Sub
End Class